package com.javabasic.algorithm.leetcode;

/**
 * @author xiongmin
 * @version 0.0.1
 * @description Created by work on 2021/10/18 8:37 下午
 * @see
 */
public class NumberComplement {

    /**
     * 题目可以转换为  num的二进制和全1 进行异或运算
     * @param num
     * @return
     */
    public int findComplement(int num) {
        long tag = 1;
        while (tag <= num) {
            tag <<= 1;
        }
        return (int) ((tag-1)^num);
    }
}
